<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var p1 = new Promise((resolve,reject)=>{
        //     if(Math.random()>0.5){
        //         resolve()
        //     }else{
        //         reject();
        //     }
        // })
        // p1.then(r=>{
        //     console.log("成功！");
        // }).catch(e=>{
        //     console.log("失败！");
        // }).finally(()=>{
        //     console.log("this is finally!");
        // })

        console.log("====");
        Promise.race([
            new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    reject("失败！");
                },3000)
            }),
            new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    resolve("成功！");
                },2000)
            }),
        ])
        .then(r=>{
            console.log(r);
        })
        .catch(r=>{
            console.log(r);
        })
    </script>
</body>
</html>